package com.bk.controller.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bk.entity.CardInfo;
import com.bk.entity.UserInfo;
import com.bk.service.cardInfo.CardInfoService;
import com.bk.service.userInfo.UserInfoService;
import com.bk.util.ReturnUtil;
import com.bk.vo.UserCardInfoVo;

@RestController /** 用户模块：开户，销户等 */
public class UserController {

	@Autowired
	private CardInfoService cardInfoService;

	@Autowired
	private UserInfoService userInfoService;

	@PostMapping("/firstOpenAccount") /** 第一次开户 */
	public ReturnUtil<CardInfo> openFirstAccount(UserInfo userInfo, CardInfo cardInfo) {
		ReturnUtil<CardInfo> rc = cardInfoService.firstCreateAccount(cardInfo, userInfo);
		return rc;
	}

	@PostMapping("/nofirstOpenAccount")
	public ReturnUtil<CardInfo> NofirstOpenAccount(UserInfo userInfo, CardInfo cardInfo) {
		ReturnUtil<CardInfo> rc = cardInfoService.nofirstCreateAccount(userInfo, cardInfo);
		return rc;
	}

	@PostMapping("/queryAccountInfo") /** 查询用户信息 */
	public ReturnUtil<UserInfo> queryAccountInfo(@RequestParam("cardId") String cardId) {
		ReturnUtil<UserInfo> rc = userInfoService.queryAccountInfo(cardId);
		return rc;
	}
	
	@PostMapping("/queryUserInfoList") /** 获取所有客户信息 */
	public ReturnUtil<UserInfo> queryUserInfoList() {
		ReturnUtil<UserInfo> rc = userInfoService.queryUserInfoList();
		return rc;
	}
	
	@PostMapping("/getUserInfoByUidAndName") /** 通过身份证以及客户名查询客户信息 */
	public ReturnUtil<UserCardInfoVo> getUserInfoByUidAndName(@RequestParam("uName") String uName,@RequestParam("uId") String uId) {
		ReturnUtil<UserCardInfoVo> rc = userInfoService.getUserInfoByUidAndName(uName,uId);
		return rc;
	}
}
